﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WindowsGame1
{
    class Tile : BaseObject
    {
        public bool m_bIsSolid;
        public int m_nTileID;

        public Tile()
        {
            m_ObjectType = OBJ_TYPE.OBJ_TILE;
        }

        public override void Update(float deltaT, Microsoft.Xna.Framework.Input.KeyboardState LastKeyState)
        {
            
        }

        public override void Render(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Camera cam)
        {
            if ((cam.m_Position - m_Position).Length() < 2000)
            {

                spriteBatch.Draw(LevelManager.Instance.m_TileSheet,
                                new Rectangle((int)(m_Position.X * cam.m_fZoom) - (int)cam.m_Position.X, (int)(m_Position.Y*cam.m_fZoom) - (int)cam.m_Position.Y, (int)(LevelManager.Instance.m_TileSize.X * cam.m_fZoom), (int)(LevelManager.Instance.m_TileSize.Y*cam.m_fZoom)),
                                new Rectangle((int)(m_nTileID % LevelManager.Instance.m_TileSheetSize.X) * (int)LevelManager.Instance.m_TileSize.X, (int)(m_nTileID / LevelManager.Instance.m_TileSheetSize.X) * (int)LevelManager.Instance.m_TileSize.Y, (int)LevelManager.Instance.m_TileSize.X, (int)LevelManager.Instance.m_TileSize.Y),
                                Color.White);

            }
            
        }

        public override void CollisionResponse(BaseObject other)
        {
            //base.CollisionResponse(other);
        }
    }
}
